]> git.r.bdr.sh - rbdr/super-polarity/blobdiff - Super Polarity/MainShip.cs
Moves to ActorManager arch + Actor Inherited stuff
[rbdr/super-polarity] / Super Polarity / MainShip.cs
index ac7a775208b14122dc7774d55a43c69dfd4bab80..92ccab798fff4d3b6206e8f0e43d7bc8e2c7f583 100644 (file)
@@ -8,51 +8,22 @@ using Microsoft.Xna.Framework.Graphics;
 
 namespace SuperPolarity
 {
-    class MainShip
+    class MainShip : Ship
     {
-        public Texture2D PlayerTexture;
-        public Vector2 Position;
-        public Vector2 Origin;
-        public bool Active;
-        public int Lives;
-        public int Multiplier;
-        public int Score;
-        public float Angle;
-
-        // Physics Properties
-        Vector2 Velocity;
-        Vector2 Acceleration;
-
-        float MaxVelocity;
-        float AccelerationRate;
+        
+        uint Multiplier;
+        uint Lives;
+        uint Score;
         ParticleEngine particleEngine;
 
-        public int Width
+        public override void Initialize(ContentManager Content, Texture2D texture, Vector2 position)
         {
-            get { return PlayerTexture.Width; }
-        }
+            base.Initialize(Content, texture, position);
 
-        public int Height
-        {
-            get { return PlayerTexture.Height; }
-        }
-
-        public void Initialize(ContentManager Content, Texture2D texture, Vector2 position)
-        {
-            PlayerTexture = texture;
-            Position = position;
-            Active = true;
             Multiplier = 1;
             Lives = 3;
             Score = 0;
 
-            Origin = new Vector2(PlayerTexture.Width / 2, PlayerTexture.Height / 2);
-            Velocity = new Vector2(0, 0);
-            Acceleration = new Vector2(0, 0);
-
-            MaxVelocity = 5;
-            AccelerationRate = 10;
-
             List<Texture2D> texturesList = new List<Texture2D>();
             texturesList.Add(Content.Load<Texture2D>("Graphics\\circle"));
             texturesList.Add(Content.Load<Texture2D>("Graphics\\diamond"));
@@ -79,108 +50,17 @@ namespace SuperPolarity
             Acceleration.Y = value * AccelerationRate;
         }
 
-        public void AutoDeccelerate(GameTime gameTime)
+        public override void Update(GameTime gameTime)
         {
-            if (Acceleration.X == 0 && Velocity.X > 0) {
-                if (AccelerationRate * gameTime.ElapsedGameTime.TotalSeconds > Velocity.X)
-                {
-                    Velocity.X = 0;
-                    Acceleration.X = 0;
-                }
-                else
-                {
-                    Acceleration.X = -AccelerationRate;
-                }
-            }
-
-            if (Acceleration.X == 0 && Velocity.X < 0)
-            {
-                if (-AccelerationRate * gameTime.ElapsedGameTime.TotalSeconds < Velocity.X)
-                {
-                    Velocity.X = 0;
-                    Acceleration.X = 0;
-                }
-                else
-                {
-                    Acceleration.X = AccelerationRate;
-                }
-            }
-
-            if (Acceleration.Y == 0 && Velocity.Y > 0)
-            {
-                if (AccelerationRate * gameTime.ElapsedGameTime.TotalSeconds > Velocity.Y)
-                {
-                    Velocity.Y = 0;
-                    Acceleration.Y = 0;
-                }
-                else
-                {
-                    Acceleration.Y = -AccelerationRate;
-                }
-            }
-
-            if (Acceleration.Y == 0 && Velocity.Y < 0)
-            {
-                if (-AccelerationRate * gameTime.ElapsedGameTime.TotalSeconds < Velocity.Y)
-                {
-                    Velocity.Y = 0;
-                    Acceleration.Y = 0;
-                }
-                else
-                {
-                    Acceleration.Y = AccelerationRate;
-                }
-            }
-        }
-
-        public void Update(GameTime gameTime)
-        {
-            Move(gameTime);
-            ChangeAngle();
+            base.Update(gameTime);
             particleEngine.EmitterLocation = Position;
             particleEngine.Update();
         }
 
-        public void Move(GameTime gameTime)
-        {
-            AutoDeccelerate(gameTime);
-
-            Velocity.X = Velocity.X + Acceleration.X * (float) gameTime.ElapsedGameTime.TotalSeconds;
-            Velocity.Y = Velocity.Y + Acceleration.Y * (float) gameTime.ElapsedGameTime.TotalSeconds;
-
-            if (Velocity.X > MaxVelocity)
-            {
-                Velocity.X = MaxVelocity;
-            }
-
-            if (Velocity.X < -MaxVelocity)
-            {
-                Velocity.X = -MaxVelocity;
-            }
-
-            if (Velocity.Y > MaxVelocity)
-            {
-                Velocity.Y = MaxVelocity;
-            }
-
-            if (Velocity.Y < -MaxVelocity)
-            {
-                Velocity.Y = -MaxVelocity;
-            }
-
-            Position.X = Position.X + Velocity.X;
-            Position.Y = Position.Y + Velocity.Y;
-        }
-
-        public void ChangeAngle()
-        {
-            Angle = (float) Math.Atan2(Velocity.Y, Velocity.X);
-        }
-
-        public void Draw(SpriteBatch spriteBatch)
+        public override void Draw(SpriteBatch spriteBatch)
         {
             particleEngine.Draw(spriteBatch);
-            spriteBatch.Draw(PlayerTexture, Position, null, Color.White, Angle, Origin, 1f, SpriteEffects.None, 0f);
+            base.Draw(spriteBatch);
         }
     }
 }